﻿using Konveyer.Core.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Konveyer.Core.Tools
{
    /// <summary>
    /// Standard instance Provider if no other is supplied
    /// </summary>
    class KonveyerInstanceProvider : IInstanceProvider
    {
        private static Ninject.IKernel Kernel = new Ninject.StandardKernel() ;

        public T Get<T>()
            where T :class 
        {
            var rtn = Kernel.GetService(typeof(T)) as T;
            return rtn;
        }

        public object Get(Type type)
        {
            var rtn = Kernel.GetService(type);
            return rtn;
        }

        public void Register<T>(Type type)
        {
            Kernel.Bind<T>().To(type);
        }

        public void Register<T>(T instance)
        {
            Kernel.Bind<T>().ToConstant(instance);
        }
    }
}
